<template>
  <el-dialog title="新增工单" width="600px" :visible="addVisible" :before-close="addVisiblefn">
    <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="100px">
      <el-form-item label="设备编号：" prop="innerCode">
        <el-input v-model="form.innerCode" autocomplete="off" placeholder="请输入" />
      </el-form-item>
      <el-form-item label="工单类型：" prop="productType">
        <el-select v-model="form.productType" placeholder="请选择" autocomplete="off">
          <el-option
            v-for="item in cutList"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="运维人员：" prop="userId">
        <el-select v-model="form.userId" placeholder="请选择">
          <!-- <el-option label="投放工单" value="shanghai" /> -->
        </el-select>
      </el-form-item>
      <el-form-item label="备注：" prop="desc">
        <el-input
          v-model="form.desc"
          type="textarea"
          autocomplete="off"
          placeholder="请输入备注（不少于40字）"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="addVisiblefn">取 消</el-button>
      <el-button type="primary">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { allTaskApi, userSearch, operatorList } from '@/api/task'
export default {
  name: 'ElDkdPCAdd',
  props: {
    addVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {},
      cutList: {},
      rules: {
        innerCode: [
          { required: true, message: '请输入', trigger: 'blur' }
        ],
        productType: [
          { required: true, message: '请选择', trigger: 'blur' }

        ],
        userId: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        desc: [
          { required: true, message: '请输入', trigger: 'blur' }

        ]

      }
    }
  },
  created() {
    this.allTaskApi()
    // this.userSearch()
    // this.operatorList()
  },

  mounted() {},

  methods: {
    addVisiblefn() {
      this.$emit('update:addVisible', false)
      this.$refs.form.resetFields()
    },
    async allTaskApi() {
      this.cutList = await allTaskApi()
      // console.log(res)
    },
    async userSearch() {
      const res = await userSearch({ isRepair: true })
      console.log(res)
    },
    async operatorList() {
      const res = await operatorList()
      console.log(res)
    }
  }
}
</script>

<style lang="scss" scoped>
.el-form {
  padding: 0 50px;
}
.el-select {
  width: 100%;
}
::v-deep .el-form-item__label {
  line-height: 55px;
}
</style>
